package spark.core.scala

import org.apache.spark.{SparkContext, SparkConf}

/**
 * spark持久化操作
 */
object Persisit {

  def main(args: Array[String]) {
    val conf = new SparkConf()
      .setAppName("Persisit").setMaster("local")
    val sc = new SparkContext(conf)
    var start = System.currentTimeMillis
    var lines = sc.textFile("datas/wordcount.txt")
    var end: Long = System.currentTimeMillis
    System.out.println("use time is " + (end - start))
    start = System.currentTimeMillis
    lines = sc.textFile("datas/wordcount.txt").cache
    lines.count
    end = System.currentTimeMillis
    System.out.println("after cache,use time is " + (end - start))
  }
}
